unit SettingsUnit;

interface

uses
  PtSettings, Forms;

type
  TMyEnum = (nABC, nXYZ, n123);
  TMyEnums = set of TMyEnum;

  TSimpleTypes = class(TSettingsGroup)
  private
    fStr2: string;
    fStr1: string;
    fInt2: integer;
    fInt1: integer;
    fFail: Double;
  published
    property  Str1: string  read fStr1  write fStr1;
    property  Str2: string  read fStr2  write fStr2;
    property  Int1: integer read fInt1  write fInt1;
    property  Int2: integer read fInt2  write fInt2;
//    property  Fail: Double  read fFail  write fFail;
  end;

  TUISettings = class(TSettingsGroup)
  private
    fStartPosition: TPosition;
    fStartMaximised: Boolean;
    fInt2: integer;
    fInt1: integer;
    fFail: Double;
    fStr1: string;
  published
    property  StartPosition: TPosition  read fStartPosition  write fStartPosition;
    property  StartMaximised: Boolean  read fStartMaximised  write fStartMaximised;
    property  Str1: string  read fStr1  write fStr1;
  end;

  TSettings = class(TSettingsGroup)
  private
    fSimpleTypes: TSimpleTypes;
    fUISettings: TUISettings;
    fCount1: integer;
    fText2: string;
    fText1: string;
    fYesNo: Boolean;
    fMyEnum: TMyEnum;
    fMyEnums: TMyEnums;
  public
    constructor Create(const AName: string; const AParent: TSettingsGroup = nil); override;
    property  SimpleTypes: TSimpleTypes read fSimpleTypes;
    property  UISettings: TUISettings read fUISettings;
  published
    property  Text1   : string    read fText1   write fText1;
    property  Text2   : string    read fText2   write fText2;
    property  Count1  : integer   read fCount1  write fCount1;
    property  YesNo   : Boolean   read fYesNo   write fYesNo;
    property  MyEnum  : TMyEnum   read fMyEnum  write fMyEnum;
    property  MyEnums : TMyEnums  read fMyEnums write fMyEnums;
  end;

var
  Settings: TSettings;
  Storage: ISettingsStorage;

implementation

procedure InitializeSettings;
begin
  Settings  := TSettings.Create('Settings', nil);
end;

procedure FinalizeSettings;
begin
  Settings.Free;
end;

{ TSettings }

constructor TSettings.Create(const AName: string; const AParent: TSettingsGroup);
begin
  inherited;
  fSimpleTypes := TSimpleTypes.Create('SimpleTypes', Self);
  fUISettings := TUISettings.Create('UISettings', Self);
end;

initialization
  InitializeSettings;

finalization
  FinalizeSettings;

end.
 
